/** ###################################################################
**     Filename  : Events.C
**     Project   : sensortest07
**     Processor : 56F8013VFAE
**     Component : Events
**     Version   : Driver 01.03
**     Compiler  : Metrowerks DSP C Compiler
**     Date/Time : 2012/3/21, 13:23
**     Abstract  :
**         This is user's event module.
**         Put your event handler code here.
**     Settings  :
**     Contents  :
**         TI1_OnInterrupt - void TI1_OnInterrupt(void);
**         AD1_OnEnd       - void AD1_OnEnd(void);
**
** ###################################################################*/
/* MODULE Events */

#include "Cpu.h"
#include "Events.h"
#include "sensor.h"

/* User includes (#include below this line is not maintained by Processor Expert) */

unsigned int oneMsCounter;
unsigned int tenMsCounter;
bool debugFlag;
//---------------------------------------------------------------------
/*
** ===================================================================
**     Event       :  TI1_OnInterrupt (module Events)
**
**     Component   :  TI1 [TimerInt]
**     Description :
**         When a timer interrupt occurs this event is called (only
**         when the component is enabled - <Enable> and the events are
**         enabled - <EnableEvent>). This event is enabled only if a
**         <interrupt service/event> is enabled.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
#pragma interrupt called /* Comment this line if the appropriate 'Interrupt preserve registers' property */
                         /* is set to 'yes' (#pragma interrupt saveall is generated before the ISR)      */
void TI1_OnInterrupt(void)
{
  oneMsCounter++;
  tenMsCounter++;
  if(oneMsCounter == 1)
  {
     updataSensor();  		
  }
  else if(oneMsCounter == 2)
  {
    		
  }
  else if(oneMsCounter == 3)
  {
  	AngleCalculate();
  }
  else if(oneMsCounter == 4)
  {
  	
  }
  else if(oneMsCounter == 5)
  {
  	oneMsCounter = 0; 
  }
  
  if(tenMsCounter == 30)
  {
  	debugFlag = 1;
  	tenMsCounter = 0;
  }
}

/*
** ===================================================================
**     Event       :  AD1_OnEnd (module Events)
**
**     Component   :  AD1 [ADC]
**     Description :
**         This event is called after the measurement (which consists
**         of <1 or more conversions>) is/are finished.
**         The event is available only when the <Interrupt
**         service/event> property is enabled.
**     Parameters  : None
**     Returns     : Nothing
** ===================================================================
*/
#pragma interrupt called /* Comment this line if the appropriate 'Interrupt preserve registers' property */
                         /* is set to 'yes' (#pragma interrupt saveall is generated before the ISR)      */
void AD1_OnEnd(void)
{
  /* Write your code here ... */
}

/* END Events */

/*
** ###################################################################
**
**     This file was created by Processor Expert 3.00 [04.35]
**     for the Freescale 56800 series of microcontrollers.
**
** ###################################################################
*/
